package com.fbli.service.Impl;

import com.fbli.entity.PageResult;
import com.fbli.mapper.QuestionMapper;
import com.fbli.pojo.Question;
import com.fbli.service.QuestionService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    QuestionMapper questionMapper;
    @Override
    public List<Question> selectAll() {
        List<Question> questions = questionMapper.selectAll();
        return questions;
    }

    @Override
    public PageResult selectPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        /*int start=(pageNum-1)*pageSize;*/
        List<Question> questions = questionMapper.selectAll();
        PageInfo<Question> page = new PageInfo<>(questions);
        return new PageResult(page.getTotal(),page.getList());
    }
}
